from flask import render_template, redirect, session, url_for, flash
from flask_login import logout_user, login_required
from . import auth


@auth.route('/auth/login', methods=['GET'])
def login():
    return render_template('auth/login.html', oauth_login_url_qq=url_for('social.social_redirict', connect_type='qq'), \
                           oauth_login_url_douban=url_for('social.social_redirict', connect_type='douban'), \
                           oauth_login_url_weibo=url_for('social.social_redirict', connect_type='weibo'))


@auth.route('/auth/logout', methods=['GET'])
@login_required
def logout():
    logout_user()
    ##TODO 最终要把这里的去掉，希望能完全由 Flask-Login 来管理
    # session.pop('douban_touken', None)
    # session.pop('qq_token', None)
    # session.pop('weibo_token', None)
    # flash('退出成功')
    return redirect(url_for('main.index'))
